# -*- coding:utf-8 -*-
"""
 查找电脑里的大文件
"""
import os
from lib.path import list_dir

bs =['Bytes', 'KB', 'MB', 'GB']


def filte_size(bsize=1048576):
    return lambda file_path: os.stat(file_path).st_size > bsize

def diplay_size(size):
    i = 0
    while size > 1024. and i <len(bs):
        size /= 1024
        i += 1
    return "{0:.2}{1}".format(size, bs[i])


if __name__ == '__main__':
    for path in list_dir("F:\\", True, filte_size(1048576000)):
        print(path, diplay_size(os.stat(path).st_size))